<?php
    include_once '../connection/databaseHandler.php';
    $database = new DatabaseHandler();

    $id = $_GET['id'];
    $query = "SELECT * FROM ".$database->t_blocked_user." WHERE username='".$id."'";
    $result = $database->execQuery($query);
    $count = mysql_num_rows($result);

    if ($count==0) {
        // blok dia
        $query = "INSERT INTO ".$database->t_blocked_user." (username) VALUES ('".$id."')";
        $result = $database->execQuery($query);
    }
    else {
        // unblok
        $query = "DELETE FROM ".$database->t_blocked_user." WHERE username='".$id."'";
        $result = $database->execQuery($query);
    }
    
    header("location:../admin.php?ref=blockSuccess");
?>
